import { mapGetters, createNamespacedHelpers } from "vuex"
import { useMapper } from "./useMapper"

export function useGetters(moduleName, mapper) {
  let mapperFN = mapGetters
  if (typeof moduleName === "string" && moduleName.length > 0) {
    mapperFN = createNamespacedHelpers(moduleName).mapGetters
  } else {
    mapper = moduleName
  }
  return useMapper(mapper, mapperFN)
}